package frameworks

import "fmt"

type Array struct {
	content []any
}

func (a *Array) Append(ele ...any) {
	for _, e := range ele {
		a.content = append(a.content, e)
	}

}
func (a *Array) AppendUnique(ele any) {
	b := false
	for i := 0; i < len(a.content); i++ {
		fmt.Println(a.content[i], ele, a.content[i] == ele)
		if a.content[i] == ele {
			b = true
		}
	}
	if b == false {
		a.Append(ele)
	}
}
func (a *Array) RemoveElement(ele any) {
	for i, e := range a.content {
		if e == ele {
			a.content = append(a.content[:i], a.content[i+1:]...)
		}
	}
}
func (a *Array) RemoveAt(index int) {
	a.content = append(a.content[:index], a.content[index+1:]...)
}
func (a *Array) RemoveAll() {
	a.content = a.content[:0]
}
func (a *Array) ForEach(f func(i int, e any)) {
	for i, a2 := range a.content {
		f(i, a2)
	}
}

func (a *Array) Length() int {
	return len(a.content)
}
